#include <iostream>

#include<algorithm>
using namespace std;

const int N = 2e5 + 10;

typedef pair<int, int> PII;
PII arr[N];
int n, k;

bool compare(PII& a, PII& b)
{
	if (a.second != b.second) return a.second > b.second;
	else
	{
		return a.first < b.first;
	}
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> arr[i].first;
	for (int i = 0; i < n; i++) cin >> arr[i].second;

	sort(arr, arr + n, compare);
	int s = 0, t = 0;
	for (int i = 0; i < k; i++)
	{
		s += arr[i].first;
		t += arr[i].second;
	}
	cout << s << t;




}
